package com.ruoyi.security.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.security.mapper.AfElevatorMaintenanceMapper;
import com.ruoyi.security.domain.AfElevatorMaintenance;
import com.ruoyi.security.service.IAfElevatorMaintenanceService;

/**
 * 电梯维保单Service业务层处理
 *
 * @author cjie
 * @date 2022-07-25
 */
@Service
public class AfElevatorMaintenanceServiceImpl implements IAfElevatorMaintenanceService {
    @Autowired
    private AfElevatorMaintenanceMapper afElevatorMaintenanceMapper;

    /**
     * 查询电梯维保单
     *
     * @param orderNo 电梯维保单ID
     * @return 电梯维保单
     */
    @Override
    public AfElevatorMaintenance selectAfElevatorMaintenanceById(String orderNo) {
        return afElevatorMaintenanceMapper.selectAfElevatorMaintenanceById(orderNo);
    }

    /**
     * 查询电梯维保单列表
     *
     * @param afElevatorMaintenance 电梯维保单
     * @return 电梯维保单
     */
    @Override
    public List<AfElevatorMaintenance> selectAfElevatorMaintenanceList(AfElevatorMaintenance afElevatorMaintenance) {
        return afElevatorMaintenanceMapper.selectAfElevatorMaintenanceList(afElevatorMaintenance);
    }

    /**
     * 新增电梯维保单
     *
     * @param afElevatorMaintenance 电梯维保单
     * @return 结果
     */
    @Override
    public int insertAfElevatorMaintenance(AfElevatorMaintenance afElevatorMaintenance) {
        afElevatorMaintenance.setOrderNo(IdUtil.getSnowflake(0, 0).nextIdStr());
        afElevatorMaintenance.setCreateTime(DateUtils.getNowDate());
        afElevatorMaintenance.setCreateBy(SecurityUtils.getUsername());
        return afElevatorMaintenanceMapper.insertAfElevatorMaintenance(afElevatorMaintenance);
    }

    /**
     * 修改电梯维保单
     *
     * @param afElevatorMaintenance 电梯维保单
     * @return 结果
     */
    @Override
    public int updateAfElevatorMaintenance(AfElevatorMaintenance afElevatorMaintenance) {
        return afElevatorMaintenanceMapper.updateAfElevatorMaintenance(afElevatorMaintenance);
    }

    /**
     * 批量删除电梯维保单
     *
     * @param orderNos 需要删除的电梯维保单ID
     * @return 结果
     */
    @Override
    public int deleteAfElevatorMaintenanceByIds(String[] orderNos) {
        return afElevatorMaintenanceMapper.deleteAfElevatorMaintenanceByIds(orderNos);
    }

    /**
     * 删除电梯维保单信息
     *
     * @param orderNo 电梯维保单ID
     * @return 结果
     */
    @Override
    public int deleteAfElevatorMaintenanceById(String orderNo) {
        return afElevatorMaintenanceMapper.deleteAfElevatorMaintenanceById(orderNo);
    }

    @Override
    public AfElevatorMaintenance selectLastAfElevatorMaintenance(AfElevatorMaintenance o) {
        return afElevatorMaintenanceMapper.selectLastAfElevatorMaintenance(o);
    }
}
